<?php echo $html->script('ordencompras/addedit.js'); ?>
<div id="ordencompraDialog" class="hide">
	<h2 id="summary"></h2>
	<?php echo $form->create('Ordencompra', array('controller'=>'ordencompras', 'action'=>'actualizar')); 
			echo $form->input('id', array('label'=>false, 'div'=>false, 'class'=>'FormElement hide'));
			echo $form->text('ordencompraestado_id', array('label'=>false, 'div'=>false, 'class'=>'FormElement hide'));
	?>
		<table class="tablaFormHeader"><?php echo
			'<tr>'
				.'<td>'.$form->label('Documento.numero_serie', __('Numero', true)).' </td>'
				.'<td>'.$form->input('Documento.numero_serie', array('label'=>false,'div'=>false, 'size'=>'20','class'=>'text ui-widget-content ui-corner-all', 'readonly'=>true)).'</td>'
				
				.'<td>'.$form->label('igv', __('Impuesto (IGV)', true)).' </td>'
				.'<td>'.$form->input('igv', array('value'=>empty($this->data['Ordencompra']['igv'])?18:$this->data['Ordencompra']['igv'],'label'=>false,'div'=>false, 'size'=>'20', 'class'=>'number recalcularPrecio FormElement text_right text ui-widget-content ui-corner-all')).'&nbsp;%</td>'
			.'</tr>'
			
			.'<tr>'
				.'<td>'.$form->label('proveedor_id', __('Proveedor', true)).' </td>'
				.'<td>'.$form->input('proveedor_id', array('label'=>false,'div'=>false, 'class'=>'FormElement text ui-widget-content ui-corner-all')).'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>'
				
				.'<td>'.$form->label('descuento', __('Descuento', true)).'&nbsp;&nbsp;&nbsp;</td>'
				.'<td>'.$form->input('descuento', array('value'=>empty($this->data['Ordencompra']['descuento'])?0:$this->data['Ordencompra']['descuento'],'label'=>false,'div'=>false, 'size'=>'20', 'class'=>'number recalcularPrecio FormElement text_right text ui-widget-content ui-corner-all')).'&nbsp;%</td>'
			.'</tr>'
			
			.'<tr>'
				.'<td>'.$form->label('moneda_id', __('Moneda', true)).' </td>'
				.'<td>'.$form->input('moneda_id', array('label'=>false,'div'=>false, 'class'=>'FormElement text ui-widget-content ui-corner-all')).'</td>'
				
				.'<td>'.$form->label('flete', __('Flete', true)).' </td>'
				.'<td>'.$form->input('flete', array('value'=>empty($this->data['Ordencompra']['flete'])?0:$this->data['Ordencompra']['flete'],'label'=>false,'div'=>false, 'size'=>'20', 'class'=>'number recalcularPrecio FormElement text_right text ui-widget-content ui-corner-all')).'</td>'
			.'</tr>'
			
			.'<tr>'
				.'<td>'.$form->label('documentoreferencia', __('Doc. Referencia', true)).'&nbsp;&nbsp;&nbsp;&nbsp;</td>'
				.'<td>'.$form->input('documentoreferencia', array('label'=>false,'div'=>false, 'size'=>'40', 'class'=>'FormElement text ui-widget-content ui-corner-all')).'</td>'
				
				.'<td>'.$form->label('gastos', __('Gastos', true)).' </td>'
				.'<td>'.$form->input('gastos', array('value'=>empty($this->data['Ordencompra']['gastos'])?0:$this->data['Ordencompra']['gastos'],'text-align'=>'right', 'label'=>false,'div'=>false, 'size'=>'20', 'class'=>'number recalcularPrecio FormElement text_right text ui-widget-content ui-corner-all')).'</td>'
			.'</tr>'
			
			.'<tr>'		
				.'<td>'.$form->label('observacion', __('Observaciones', true)).' </td>'
				.'<td colspan=3>'?> <textarea cols=110 class="FormElement text ui-widget-content ui-corner-all" name="data[Ordencompra][observacion]" id="OrdencompraObservacion"></textarea> 
				</td>
			</tr>
		</table>

		<br/>
		<table id="detalleordencomprasForm" class="tablaForm">
			<thead>
				<tr>
					<th class="header">Codigo - Descripcion</th>
					<th class="header">Und x Cj</th>
					<th class="header">Unidad</th>
					<th class="header">Cantidad</th>
					<th class="header">Pc. Unidad</th>
					<th class="header">Pc. Total</th>
					<th class="header">Observacion</th>
					<td><?php echo $form->button('+', array('type'=>'button','div'=>false, 'label'=>false, 'class'=>'ui-state-default ui-corner-all',
															'onClick'=>'agregarRegistro()')) ?></td>
				</tr>	
			</thead>
			<tbody><?php  //artificio para la generacion del primer detalle
			if(empty($this->data['Detalles'])){
				$this->data['Detalles'][0] = array('Articulo'=>array('descripcion'=>''));
			}
			
			foreach($this->data['Detalles'] as $key=>$detalleordencompras):	
			echo
		 	'<tr class="ui-widget-content jqgrow ui-row-ltr">'
				.'<td>'.$form->input('Detalles.'.$key.'.Articulo.descripcion', array('maxlenght'=>'2', 'label'=>false,'div'=>false, 'size'=>'38', 'class'=>'articuloDescripcion text ui-widget-content required'))
						.$form->hidden('Detalles.'.$key.'.Detalleordencompra.articulo_id',array('label'=>false,'class'=>'required'))
				.'</td>'
				.'<td>'.$form->input('Detalles.'.$key.'.Articulo.unidadxcaja', array('readonly'=>true,'label'=>false,'div'=>false, 'size'=>'10', 'class'=>'readonly text_right text ui-widget-content')).'</td>'
				.'<td>'.$form->input('Detalles.'.$key.'.Unidad.descripcion', array('readonly'=>true,'label'=>false,'div'=>false, 'size'=>'10', 'class'=>'readonly text ui-widget-content')).'</td>'
				.'<td>'.$form->input('Detalles.'.$key.'.Detalleordencompra.cantidad', array('label'=>false,'div'=>false, 'size'=>'10', 'class'=>'required number recalcularPrecio text_right text ui-widget-content')).'</td>'
				.'<td>'.$form->input('Detalles.'.$key.'.Detalleordencompra.prc_unidad', array('label'=>false,'div'=>false, 'size'=>'10','class'=>'required number recalcularPrecio text_right text ui-widget-content')).'</td>'
				.'<td>'.$form->input('Detalles.'.$key.'.Detalleordencompra.prc_total', array('readonly'=>true,'label'=>false,'div'=>false, 'size'=>'10', 'class'=>'FormElement text_right text ui-widget-content')).'</td>'
				.'<td>'.$form->input('Detalles.'.$key.'.Detalleordencompra.observacion', array('label'=>false,'div'=>false, 'size'=>'20', 'class'=>'FormElement text ui-widget-content')).'</td>'
				.'<td>'.$form->button('--', array('type'=>'button','div'=>false, 'label'=>false, 'class'=>'eliminarRegistro ui-state-default ui-corner-all','onClick'=>'eliminarRegistro($(this))')).'</td>'
			.'</tr>';
			endforeach;
			?></tbody>
		</table>
		<br/>
		<div class="prepend-15">
			<table class="tablaFormHeader">
				<tbody>
				<?php echo
				'<tr>'
					.'<td>'.$form->label('prc_total_sigv',__('Precio Total S/IGV',true)).'</td>'
					.'<td>'.$form->input('prc_total_sigv', array('class'=>'text_right ui-widget-content','div'=>false, 'label'=>false, 'size'=>10, 'readonly'=>true)).'</td>'
				.'</tr>'
				.'<tr>'
					.'<td class="text_right">'.$form->label('prc_igv',__('IGV',true)).'</td>'
					.'<td>'.$form->input('prc_igv', array('class'=>'text_right ui-widget-content','div'=>false, 'label'=>false, 'size'=>10, 'readonly'=>true)).'</td>'
				.'</tr>'
				.'<tr>'
					.'<td>'.$form->label('prc_total_cigv',__('Precio Total C/IGV',true)).'</td>'
					.'<td>'.$form->input('prc_total_cigv', array('class'=>"text_right ui-widget-content",'div'=>false, 'label'=>false, 'size'=>10, 'readonly'=>true)).'</td>'
				.'</tr>';
				?>
				</tbody>
			</table>
		</div>
			
		
	<?php echo $form->end(); ?>
</div>